/*     */ package com.infoservice.schedule;
/*     */ 
/*     */ import com.infoservice.po3.POFactory;
/*     */ import com.infoservice.po3.POFactoryBuilder;
/*     */ import com.infoservice.po3.core.context.POContext;
/*     */ import com.infoservice.po3.core.util.ContextUtil;
/*     */ import com.infoservice.schedule.generator.TaskMng;
/*     */ import com.infoservice.schedule.po.pos.TaskInfoPO;
/*     */ import com.infoservice.schedule.po.pos.TaskPlanPO;
/*     */ import com.infoservice.schedule.queue.TaskQueue;
/*     */ import com.infoservice.schedule.util.RuntimeParameterUtil;
/*     */ import com.infoservice.schedule.worker.WorkerMng;
/*     */ import java.util.Map;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class ScheduleService
/*     */ {
/*  38 */   private static Logger logger = Logger.getLogger(ScheduleService.class);
/*  39 */   private static ScheduleService schedule = new ScheduleService();
/*     */ 
/*     */   public static ScheduleService getInstance()
/*     */   {
/*  45 */     synchronized (schedule) {
/*  46 */       if (schedule == null)
/*  47 */         schedule = new ScheduleService();
/*     */     }
/*  49 */     return schedule;
/*     */   }
/*     */   public void destory() {
/*  52 */     logger.info("Schedule Service destory start ...");
/*  53 */     TaskQueue.getInstance().stopThread();
/*  54 */     TaskMng.getInstance().destory();
/*  55 */     WorkerMng.getInstance().stopWorkMng();
/*  56 */     logger.info("Schedule Service destory success");
/*     */   }
/*     */   public void init() {
/*  59 */     logger.info("Schedule Service init start ");
/*  60 */     TaskMng tskMng = TaskMng.getInstance();
/*  61 */     tskMng.init();
/*  62 */     TaskQueue taskQueue = TaskQueue.getInstance();
/*  63 */     taskQueue.start();
/*  64 */     WorkerMng workerPool = WorkerMng.getInstance();
/*  65 */     workerPool.start();
/*  66 */     logger.info("Schedule Service init success.");
/*     */   }
/*     */ 
/*     */   public static void updateRtParams(Map<String, String> rtMap) {
/*  70 */     RuntimeParameterUtil.updateRtParams(rtMap);
/*     */   }
/*     */ 
/*     */   public void disableTask(long taskId)
/*     */   {
/*     */     try
/*     */     {
/*  80 */       POFactory factory = POFactoryBuilder.getInstance();
/*     */ 
/*  82 */       TaskInfoPO cond = new TaskInfoPO();
/*  83 */       cond.setTaskId(Long.valueOf(taskId));
/*  84 */       cond.setTaskStatus(Integer.valueOf(1));
/*     */ 
/*  86 */       TaskInfoPO value = new TaskInfoPO();
/*  87 */       value.setTaskStatus(Integer.valueOf(0));
/*     */ 
/*  89 */       TaskPlanPO tpCond = new TaskPlanPO();
/*  90 */       tpCond.setTaskId(Long.valueOf(taskId));
/*  91 */       tpCond.setPlanStatus(Integer.valueOf(1));
/*     */ 
/*  93 */       TaskPlanPO tpValue = new TaskPlanPO();
/*  94 */       tpValue.setPlanStatus(Integer.valueOf(0));
/*     */ 
/*  96 */       factory.update(cond, value);
/*  97 */       factory.update(tpCond, tpValue);
/*     */ 
/*  99 */       POContext.endTxn(true);
/* 100 */       logger.info("disable Task success! " + taskId);
/* 101 */       TaskMng.getInstance().remove(taskId);
/*     */     } catch (Throwable t) {
/* 103 */       POContext.endTxn(false);
/* 104 */       logger.error("Disable Task [taskId=" + taskId + "] error " + t.getMessage(), t);
/*     */     } finally {
/* 106 */       POContext.cleanTxn();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void disableTaskPlan(long taskId, long planId) {
/*     */     try {
/* 112 */       POFactory factory = POFactoryBuilder.getInstance();
/*     */ 
/* 114 */       TaskPlanPO tpCond = new TaskPlanPO();
/* 115 */       tpCond.setTaskId(Long.valueOf(taskId));
/* 116 */       tpCond.setPlanId(Long.valueOf(planId));
/* 117 */       tpCond.setPlanStatus(Integer.valueOf(1));
/*     */ 
/* 119 */       TaskPlanPO tpValue = new TaskPlanPO();
/* 120 */       tpValue.setPlanStatus(Integer.valueOf(0));
/*     */ 
/* 122 */       factory.update(tpCond, tpValue);
/*     */ 
/* 124 */       POContext.endTxn(true);
/* 125 */       logger.info("disable TaskPlan success!  taskId" + taskId + ",planId=" + planId);
/* 126 */       TaskMng.getInstance().removeTaskPlan(taskId, planId);
/*     */     } catch (Throwable t) {
/* 128 */       POContext.endTxn(false);
/* 129 */       logger.error("Disable TaskPlan [taskId=" + taskId + ",planId=" + planId + "] error! " + t.getMessage(), t);
/*     */     } finally {
/* 131 */       POContext.cleanTxn();
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void main(String[] args) {
/* 135 */     ContextUtil.loadConf();
/* 136 */     getInstance().init();
/*     */   }
/*     */ }

/* Location:           D:\Workspace\Work\ASMP_DE\lib\frame3\InfoSchedule_1.0.03.jar
 * Qualified Name:     com.infoservice.schedule.ScheduleService
 * JD-Core Version:    0.6.0
 */